package com.quanyan.place.biz;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.place.entity.*;
import com.quanyan.place.entity.apireq.ReqBillingInfo;
import com.quanyan.place.entity.apireq.ReqPlaceOrderListVo;
import com.quanyan.place.entity.apireq.ReqPlaceSalePlan;
import com.quanyan.place.entity.apireq.ReqSearchVo;
import com.quanyan.place.entity.apiresp.*;
import com.quanyan.place.entity.vo.PlaceCommonDataVo;
import com.quanyan.place.wrapper.PlaceOrderServiceWrapper;
import com.quanyan.search.entity.request.ReqPlaceSearchInfo;
import com.quanyan.search.entity.vo.PlaceIndexInfo;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import baidu.webapi.model.AddressComponent;

import javax.validation.constraints.NotNull;

/**
 * Created by jingliu on 16/6/1.
 */
public interface IBaseService {
    String getCityTest();

    /**
     * 获取系统已经开通的城市列表
     * @return
     */
    List<RespCityInfo> getSysCityInfo(Integer clientType);

    APIResponse<?> getCitys(Integer provinceId, boolean isActive, boolean isPublic, Double lng, Double lat);

    APIResponse<TbCity> getCity(Double lng, Double lat);

    /**
     * 根据经纬度获取百度城市对象
     * @param lat
     * @param lng
     * @return
     */
    AddressComponent getAddressInfo(Double lat, Double lng);

    /**
     * 获取系统已开通的运动项目
     * @return
     */
    List<RespCategory> getSysCategroyInfo();

    /**
     * 根据百度城市对象获取对应城市
     * @param addressComponent
     * @return
     */
    TbCity getTbCityByAddressComponent(AddressComponent addressComponent);

    /**
     * 根据百度城市对象获取对应城市
     * @param addressComponent
     * @return
     */
    TbDistrict getTbDistrictByAddressComponent(AddressComponent addressComponent);

    /**
     * 获取订场计划列表
     * @param reqPlaceSalePlan
     * @return
     */
    List<TbBizPlaceUnitSalePlan> getTbBizPlaceUnitSalePlanList(ReqPlaceSalePlan reqPlaceSalePlan);

    /**
     * 获取订场计划
     * @param reqPlaceSalePlan
     * @return
     */
    RespPlaceUnitSalePlanDetail getSalePlanDetail(ReqPlaceSalePlan reqPlaceSalePlan, Integer from, List<TbBizPlaceUnitSalePlan> resultList);

    /**
     * 获取场馆单元时间信息列表
     * @param placeId
     * @return
     */
    List<TbBizPlaceUnitTime> getTbBizPlaceUnitTimes(Integer placeId);



    /**
     * 更新场馆单元状态
     * @param placeUnitIds
     * @param state
     * @return
     */
    boolean updateTbBizPlaceUnitSalePlan(List<String> placeUnitIds, Byte state, String lockRemarks);

    /**
     * 更新场馆单元状态[包括组合场的]
     * @param placeUnitIds
     * @param state
     * @return
     */
    boolean updateTbBizPlaceUnitSalePlanEx(List<String> placeUnitIds, Byte state, String lockRemarks,String uid);

    /**
     * 获取销售单元订单ID
     * @return
     */
    String getBizOrderId(Integer uid);

    /**
     * 保存场馆订单表
     * @param tbBizPlaceOrder
     * @return
     */
    boolean saveTbBizPlaceOrder(TbBizPlaceOrder tbBizPlaceOrder);

    /**
     * 保存场馆单元表
     * @param tbBizPlaceOrderItem
     * @return
     */
    boolean saveTbBizpPlaceOrderItem(TbBizPlaceOrderItem tbBizPlaceOrderItem);

    /**
     * 转换为订单明细列表
     * @param tbBizPlaceUnitSalePlans
     * @param uid
     * @param method 0:开单 1:包场
     * @return
     */
    List<TbBizPlaceOrderItem> salePlans2OrderItem(List<TbBizPlaceUnitSalePlan> tbBizPlaceUnitSalePlans, Integer uid, String orderid, int method,ReqBillingInfo reqBillingInfo,int useType);

    /**
     * 获取不能开单的场馆单元
     * @param tbBizPlaceUnitSalePlans
     * @return
     */
    TbBizPlaceUnitSalePlan getNotSellPlan(List<TbBizPlaceUnitSalePlan> tbBizPlaceUnitSalePlans);

    /**
     * 根据UID获取场馆订单列表
     * @param uid
     * @param pageNum
     * @param pageSize
     * @return
     */
    PageObj<List<RespUserBizPlaceOrderInfo>> getRespBizPlaceOrderInfoByUid(String mobile, Integer uid, Integer pageNum,
                                                                           Integer pageSize, Integer opType,Integer sourceType,
                        Integer orderStatus, Integer isEnable);
    
    /**
     * 根据场馆Id获取销售计划列表
     * @param placeId
     * @return
     */
    List<TbBizPlaceUnitSalePlan> getTbBizPlaceUnitSalePlansByPlaeId(Integer placeId, Integer days);

    /**
     * 根据场馆Id获取场馆经营类型
     * @param placeId
     * @return
     */
    List<TbBizPlaceCategory> getTbBizPlaceCategoryByPlaceId(Integer placeId);

    /**
     * 获取系统的运动项目map
     * @return
     */
    Map<Integer, String> getSysCategoryMap();

    RespCategory getRespCategoryByName(@NotNull String categoryName);

    /**
     * 销售计划列表转换为搜索索引销售计划列表
     * @param tbBizPlace
     * @param tbBizPlaceUnitSalePlans
     * @return
     */
    List<com.quanyan.search.entity.request.ReqPlaceSalePlan> getReqPlaceSalePlanSerach(TbBizPlace tbBizPlace, List<TbBizPlaceUnitSalePlan> tbBizPlaceUnitSalePlans);

    /**
     * 根据saleid获取场馆单元
     * @param saleids
     * @return
     */
    List<TbBizPlaceUnitSalePlan> getSalePlanUnitId(List<String> saleids);

    /**
     * 数据表对象转换为搜索场馆对象
     * @param tbBizPlace
     * @return
     */
    PlaceIndexInfo tb2InsertPlaceIndexInfo(TbBizPlace tbBizPlace);

    /**
     * 数据表销售计划对象转换为搜索销售计划对象
     * @param tbBizPlaceUnitSalePlan
     * @return
     */
    com.quanyan.search.entity.request.ReqPlaceSalePlan tbPlaceSalePlan2ReqPlaceSalePlan(TbBizPlaceUnitSalePlan tbBizPlaceUnitSalePlan);

    /**
     * 判断用户是否对场馆评价 0 未评价  1已评价
     * @param uid
     * @param placeId
     * @return
     */
    boolean hasComment(Integer uid, Integer placeId, String orderid);

    /**
     * 根据场馆Id获取场馆基本信息
     * @param placeId
     * @return
     */
    RespBizPlaceBaseInfo placeBaseInfoUtils(Integer placeId);

    /**
     * 获取销售计划
     * @param tbBizPlace
     * @param days
     * @param placeIndexInfo
     * @return
     */
    List<PlaceIndexInfo> getPlaceSalePlanSerach(
            TbBizPlace tbBizPlace,
            Integer days, PlaceIndexInfo placeIndexInfo);

    String getCommonDataCache(String key);

    APIResponse<PlaceCommonDataVo> getPlaceCommonData();

    Map<Integer, Double>  getLPrice(Integer placeId);

    List<TbBizPlaceOrderItem> adjustOrderItemPrice(BigDecimal receivedAmount, List<TbBizPlaceOrderItem> tbBizPlaceOrderItems, BigDecimal totalSalePrice);

    /**
     * 商家端  已调价订单明细 转 支付明细 
     * @param tbBizPlaceOrderItems
     * @param payType
     * @return
     */
    List<TbBizPlacePayItem> convertOrderPayItem(List<TbBizPlaceOrderItem> tbBizPlaceOrderItems,Integer payType,TbBizPlaceMemberCard tbBizPlaceMemberCard);

    /**
     * 商家端  已调价订单明细 转 折扣明细  
     * @param tbBizPlaceOrderItems
     * @param tbBizPlaceMemberCard
     * @return
     */
    List<TbBizPlaceOrderDiscountItem> convertOrderDiscountItem(List<TbBizPlaceOrderItem> tbBizPlaceOrderItems,TbBizPlaceMemberCard tbBizPlaceMemberCard);

    void placeBillingUpdatePlaceUnitSalePlan(List<TbBizPlaceOrderItem> tbBizPlaceOrderItems,byte status);

    // 更新销售计划
    int updateSalePlanByPrimaryKeyList(ReqPlaceOrderListVo reqPlaceOrderListVo);

}
